
public abstract class List<T> {

	private Node head = null;
	private Node tail = null;
	
	protected class Node {
		T element;
		Node next = null;
		Node previous = null;
		
		Node(T element) {
			this.element = element;
		}
	}
	
	public void add(T element) {
		if(head == null) {
			head = tail = new Node(element);
		} else {
			Node currTail = tail;
			Node newTail = new Node(element);
			currTail.next = newTail;
			newTail.previous = currTail;
			tail = newTail;
		}
	}
	
	public void add(List<T> elements) {
		if(elements == null) {
			return;
		}
		
		Node currentNode = elements.head;
		while(currentNode != null) {
			add(currentNode.element);
			currentNode = currentNode.next;
		}
	}
	
	protected Node getHead() {
		return head;
	}
}
